/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * insumos_salidas_consignadocxc.java
 *
 * Created on 19/05/2011, 10:14:03 AM
 */

package sie_invdis;


import java.sql.*;
import javax.swing.*;
import java.awt.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Calendar;
import java.text.ParseException;
import java.text.*;
/**
 *
 * @author Michelle
 */
public class insumos_salidas_consignadocxc extends javax.swing.JFrame {

    /** Creates new form insumos_salidas_consignadocxc */
    private javax.swing.table.DefaultTableModel jtable_modelo_catdoctos;
    private javax.swing.table.DefaultTableModel jtable_modelo_empleado;
    private javax.swing.table.DefaultTableModel jtable_modelo_empleadocxc;
    private javax.swing.table.DefaultTableModel jtable_modelo_empleadocxc_detalle;


    bd_conexion x = new bd_conexion();
    ResultSet rs = null;

    int fempleadoactual=0, fdoctoactual=0,opcioncatalogo=0,statusactual=0,controlcomboinsu=0;
    private SimpleDateFormat formateador = new SimpleDateFormat("dd-MM-yyyy");
    private SimpleDateFormat formateadoresta = new SimpleDateFormat("yyyy-MM-dd");
    String textobuscaemplea="";
    
  public insumos_salidas_consignadocxc() {
        this.iniciar_modelo_catalogocobros();
        this.iniciar_modelo_empleado();
        this.iniciar_modelo_empleado_cxc();
        this.iniciar_modelo_catalogocobros_detalle();
        initComponents();

        jt_catempleadossaldo.getColumnModel().getColumn(0).setPreferredWidth(10);//tem ent
        jt_catempleadossaldo.getColumnModel().getColumn(1).setPreferredWidth(50);//familia
        jt_catempleadossaldo.getColumnModel().getColumn(2).setPreferredWidth(160);//subfam.
        jt_catempleadossaldo.getColumnModel().getColumn(2).setPreferredWidth(50);//subfam.

        jt_catdoctoscxc.getColumnModel().getColumn(0).setPreferredWidth(50);//tem ent
        jt_catdoctoscxc.getColumnModel().getColumn(1).setPreferredWidth(25);//tem ent
        jt_catdoctoscxc.getColumnModel().getColumn(2).setPreferredWidth(160);//familia
        jt_catdoctoscxc.getColumnModel().getColumn(3).setPreferredWidth(45);//subfam.
        jt_catdoctoscxc.getColumnModel().getColumn(4).setPreferredWidth(45);//subfam.
        jt_catdoctoscxc.getColumnModel().getColumn(5).setPreferredWidth(70);//subfam.
        jt_catdoctoscxc.getColumnModel().getColumn(6).setPreferredWidth(15);//subfam.

        
         java.util.Date fecha=new Date();
         this.jdc_fechaprogramada.setDate(fecha);
         this.jdc_rangoini.setDate(fecha);
         this.jdc_rangofinal.setDate(fecha);

          if (variables_global.getnivelusu()==3)
            {
                textobuscaemplea=String.valueOf(variables_global.getdepartamento());
                opcioncatalogo=1;
                this.carga_datos_catdoctoinsucxc(1,"",Integer.valueOf(variables_global.getdepartamento()));
            }
          else
            {

                this.carga_datos_catdoctoinsucxc(0,"",0);
            }
         this.jbtn_cerrardocto.setVisible(false);
         this.jbtn_recibircorporativo.setVisible(false);
         this.jbtn_recibidireccion.setVisible(false);
         this.loadcombostatusdocto();
         controlcomboinsu=1;
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jt_catdoctoscxc = new javax.swing.JTable()
        {
            public boolean isCellEditable(int rowIndex, int mColIndex) {
                return false;
            }
        }
        ;
        jcbx_filtrostatus = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jtf_totalgral = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jtf_describe = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jdc_fechaprogramada = new com.toedter.calendar.JDateChooser();
        jLabel3 = new javax.swing.JLabel();
        jdc_rangoini = new com.toedter.calendar.JDateChooser();
        jLabel4 = new javax.swing.JLabel();
        jdc_rangofinal = new com.toedter.calendar.JDateChooser();
        jLabel5 = new javax.swing.JLabel();
        jtf_observaindica = new javax.swing.JTextField();
        jbtn_guardasolicitud = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        jt_catempleadossaldo = new javax.swing.JTable()
        {
            public boolean isCellEditable(int rowIndex, int mColIndex) {
                return false;
            }
        }
        ;
        jPanel4 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jt_empleadocxc = new javax.swing.JTable()
        {
            public boolean isCellEditable(int rowIndex, int mColIndex) {
                return false;
            }
        }
        ;
        jPanel5 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jt_catdoctoscxc_detalle = new javax.swing.JTable()
        {
            public boolean isCellEditable(int rowIndex, int mColIndex) {
                return false;
            }
        }
        ;
        jLabel6 = new javax.swing.JLabel();
        jtf_totaldocto = new javax.swing.JTextField();
        jbtn_cerrardocto = new javax.swing.JButton();
        jbtn_recibircorporativo = new javax.swing.JButton();
        jbtn_recibidireccion = new javax.swing.JButton();
        jbtn_imprimir = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jtf_fechadocto = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jtf_departamento = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jtf_describedocto = new javax.swing.JTextField();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jmni_salir = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jmni_actualizar = new javax.swing.JMenuItem();
        jmni_scape = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(sie_invdis.Sie_invdisApp.class).getContext().getResourceMap(insumos_salidas_consignadocxc.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel1.border.title"))); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        jScrollPane4.setName("jScrollPane4"); // NOI18N

        jt_catdoctoscxc.setModel(this.jtable_modelo_catdoctos);
        jt_catdoctoscxc.setName("jt_catdoctoscxc"); // NOI18N
        jt_catdoctoscxc.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jt_catdoctoscxcMouseClicked(evt);
                if(evt.getClickCount() >= 2)
                {
                    dioclickdoctos(evt);
                }
            }
        });
        jt_catdoctoscxc.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jt_catdoctoscxcMouseClicked(evt);
            }
        });
        jScrollPane4.setViewportView(jt_catdoctoscxc);

        jcbx_filtrostatus.setName("jcbx_filtrostatus"); // NOI18N
        jcbx_filtrostatus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbx_filtrostatusActionPerformed(evt);
            }
        });

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        jtf_totalgral.setEditable(false);
        jtf_totalgral.setText(resourceMap.getString("jtf_totalgral.text")); // NOI18N
        jtf_totalgral.setName("jtf_totalgral"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jcbx_filtrostatus, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 326, Short.MAX_VALUE)
                .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jtf_totalgral, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 694, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jcbx_filtrostatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtf_totalgral, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11)))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel2.border.title"))); // NOI18N
        jPanel2.setName("jPanel2"); // NOI18N

        jtf_describe.setToolTipText(resourceMap.getString("jtf_describe.toolTipText")); // NOI18N
        jtf_describe.setName("jtf_describe"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jdc_fechaprogramada.setDateFormatString(resourceMap.getString("jdc_fechaprogramada.dateFormatString")); // NOI18N
        jdc_fechaprogramada.setName("jdc_fechaprogramada"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jdc_rangoini.setDateFormatString(resourceMap.getString("jdc_rangoini.dateFormatString")); // NOI18N
        jdc_rangoini.setName("jdc_rangoini"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jdc_rangofinal.setDateFormatString(resourceMap.getString("jdc_rangofinal.dateFormatString")); // NOI18N
        jdc_rangofinal.setName("jdc_rangofinal"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jtf_observaindica.setName("jtf_observaindica"); // NOI18N

        jbtn_guardasolicitud.setIcon(resourceMap.getIcon("jbtn_guardasolicitud.icon")); // NOI18N
        jbtn_guardasolicitud.setText(resourceMap.getString("jbtn_guardasolicitud.text")); // NOI18N
        jbtn_guardasolicitud.setToolTipText(resourceMap.getString("jbtn_guardasolicitud.toolTipText")); // NOI18N
        jbtn_guardasolicitud.setName("jbtn_guardasolicitud"); // NOI18N
        jbtn_guardasolicitud.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_guardasolicitudActionPerformed(evt);
            }
        });

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addGap(25, 25, 25)
                        .addComponent(jdc_fechaprogramada, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel2)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                            .addComponent(jLabel1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jtf_describe, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                            .addComponent(jLabel3)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addComponent(jtf_observaindica, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jbtn_guardasolicitud, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addComponent(jdc_rangoini, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(12, 12, 12)
                                    .addComponent(jLabel4)
                                    .addGap(18, 18, 18)
                                    .addComponent(jdc_rangofinal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jdc_fechaprogramada, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtf_describe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(13, 13, 13)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3)
                    .addComponent(jdc_rangofinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jdc_rangoini, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jtf_observaindica, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtn_guardasolicitud))
                .addContainerGap())
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel3.border.title"))); // NOI18N
        jPanel3.setName("jPanel3"); // NOI18N

        jScrollPane5.setName("jScrollPane5"); // NOI18N

        jt_catempleadossaldo.setModel(this.jtable_modelo_empleado);
        jt_catempleadossaldo.setName("jt_catempleadossaldo"); // NOI18N
        jt_catempleadossaldo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jt_catempleadossaldoMouseClicked(evt);
                if(evt.getClickCount() >= 2)
                {
                    diodblclick(evt);
                    //System.out.println(" double click" );

                }
            }
        });
        jScrollPane5.setViewportView(jt_catempleadossaldo);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 224, Short.MAX_VALUE)
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel4.border.title"))); // NOI18N
        jPanel4.setName("jPanel4"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jt_empleadocxc.setModel(this.jtable_modelo_empleadocxc);
        jt_empleadocxc.setName("jt_empleadocxc"); // NOI18N
        jt_empleadocxc.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jt_empleadocxcMouseClicked(evt);
                if(evt.getClickCount() >= 2)
                {
                    dioclickabonar(evt);
                    //System.out.println(" double click" );
                }
            }
        });
        jScrollPane2.setViewportView(jt_empleadocxc);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel5.border.title"))); // NOI18N
        jPanel5.setName("jPanel5"); // NOI18N

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        jt_catdoctoscxc_detalle.setModel(this.jtable_modelo_empleadocxc_detalle);
        jt_catdoctoscxc_detalle.setName("jt_catdoctoscxc_detalle"); // NOI18N
        jt_catdoctoscxc_detalle.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jt_catdoctoscxc_detalleMouseClicked(evt);
                if(evt.getClickCount() >= 2)
                {
                    dioclickimprime(evt);
                    //System.out.println(" double click" );
                }
            }
        });
        jScrollPane3.setViewportView(jt_catdoctoscxc_detalle);

        jLabel6.setFont(resourceMap.getFont("jLabel6.font")); // NOI18N
        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jtf_totaldocto.setEditable(false);
        jtf_totaldocto.setFont(resourceMap.getFont("jtf_totaldocto.font")); // NOI18N
        jtf_totaldocto.setText(resourceMap.getString("jtf_totaldocto.text")); // NOI18N
        jtf_totaldocto.setName("jtf_totaldocto"); // NOI18N

        jbtn_cerrardocto.setIcon(resourceMap.getIcon("jbtn_cerrardocto.icon")); // NOI18N
        jbtn_cerrardocto.setText(resourceMap.getString("jbtn_cerrardocto.text")); // NOI18N
        jbtn_cerrardocto.setToolTipText(resourceMap.getString("jbtn_cerrardocto.toolTipText")); // NOI18N
        jbtn_cerrardocto.setName("jbtn_cerrardocto"); // NOI18N
        jbtn_cerrardocto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_cerrardoctoActionPerformed(evt);
            }
        });

        jbtn_recibircorporativo.setIcon(resourceMap.getIcon("jbtn_recibircorporativo.icon")); // NOI18N
        jbtn_recibircorporativo.setText(resourceMap.getString("jbtn_recibircorporativo.text")); // NOI18N
        jbtn_recibircorporativo.setToolTipText(resourceMap.getString("jbtn_recibircorporativo.toolTipText")); // NOI18N
        jbtn_recibircorporativo.setName("jbtn_recibircorporativo"); // NOI18N
        jbtn_recibircorporativo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_recibircorporativoActionPerformed(evt);
            }
        });

        jbtn_recibidireccion.setIcon(resourceMap.getIcon("jbtn_recibidireccion.icon")); // NOI18N
        jbtn_recibidireccion.setText(resourceMap.getString("jbtn_recibidireccion.text")); // NOI18N
        jbtn_recibidireccion.setName("jbtn_recibidireccion"); // NOI18N
        jbtn_recibidireccion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_recibidireccionActionPerformed(evt);
            }
        });

        jbtn_imprimir.setIcon(resourceMap.getIcon("jbtn_imprimir.icon")); // NOI18N
        jbtn_imprimir.setText(resourceMap.getString("jbtn_imprimir.text")); // NOI18N
        jbtn_imprimir.setName("jbtn_imprimir"); // NOI18N
        jbtn_imprimir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_imprimirActionPerformed(evt);
            }
        });

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jtf_fechadocto.setEditable(false);
        jtf_fechadocto.setText(resourceMap.getString("jtf_fechadocto.text")); // NOI18N
        jtf_fechadocto.setName("jtf_fechadocto"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jtf_departamento.setEditable(false);
        jtf_departamento.setText(resourceMap.getString("jtf_departamento.text")); // NOI18N
        jtf_departamento.setName("jtf_departamento"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jtf_describedocto.setEditable(false);
        jtf_describedocto.setText(resourceMap.getString("jtf_describedocto.text")); // NOI18N
        jtf_describedocto.setName("jtf_describedocto"); // NOI18N

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jbtn_cerrardocto)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtf_totaldocto, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE)
                        .addComponent(jbtn_recibircorporativo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbtn_recibidireccion, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jbtn_imprimir, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jtf_fechadocto, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtf_departamento, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtf_describedocto, javax.swing.GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE)))
                .addContainerGap())
            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 694, Short.MAX_VALUE)
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtf_fechadocto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtf_describedocto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(jtf_departamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbtn_cerrardocto)
                    .addComponent(jLabel6)
                    .addComponent(jtf_totaldocto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtn_recibircorporativo)
                    .addComponent(jbtn_recibidireccion)
                    .addComponent(jbtn_imprimir)))
        );

        jMenuBar1.setName("jMenuBar1"); // NOI18N

        jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
        jMenu1.setName("jMenu1"); // NOI18N

        jmni_salir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK));
        jmni_salir.setIcon(resourceMap.getIcon("jmni_salir.icon")); // NOI18N
        jmni_salir.setText(resourceMap.getString("jmni_salir.text")); // NOI18N
        jmni_salir.setName("jmni_salir"); // NOI18N
        jmni_salir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmni_salirActionPerformed(evt);
            }
        });
        jMenu1.add(jmni_salir);

        jMenuBar1.add(jMenu1);

        jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
        jMenu2.setName("jMenu2"); // NOI18N

        jmni_actualizar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F5, 0));
        jmni_actualizar.setIcon(resourceMap.getIcon("jmni_actualizar.icon")); // NOI18N
        jmni_actualizar.setText(resourceMap.getString("jmni_actualizar.text")); // NOI18N
        jmni_actualizar.setName("jmni_actualizar"); // NOI18N
        jmni_actualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmni_actualizarActionPerformed(evt);
            }
        });
        jMenu2.add(jmni_actualizar);

        jmni_scape.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0));
        jmni_scape.setText(resourceMap.getString("jmni_scape.text")); // NOI18N
        jmni_scape.setName("jmni_scape"); // NOI18N
        jmni_scape.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmni_scapeActionPerformed(evt);
            }
        });
        jMenu2.add(jmni_scape);

        jMenuBar1.add(jMenu2);

        jMenu3.setText(resourceMap.getString("jMenu3.text")); // NOI18N
        jMenu3.setName("jMenu3"); // NOI18N
        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 322, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jmni_salirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_salirActionPerformed
        // TODO add your handling code here:
        this.dispose();
    }//GEN-LAST:event_jmni_salirActionPerformed

    private void jbtn_guardasolicitudActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_guardasolicitudActionPerformed
        // TODO add your handling code here:
        if(this.jtf_describe.getText().toString().length()> 0) {
            if(JOptionPane.showConfirmDialog(null, "Desea Crear Un Nuevo Documento?")==0) {
                this.agregardoctocxc();
                this.jmni_actualizarActionPerformed(evt);
            } else {

                this.jtf_describe.requestFocus();
            }
        } else {
            //JOptionPane.showMessageDialog(null,"Antes de Guardar Especifique una Descripcion", "Sistema Integral(Indicadores) : Error",1);
            this.jtf_describe.requestFocus();
        }
}//GEN-LAST:event_jbtn_guardasolicitudActionPerformed



private void agregardoctocxc(){
      String sfechaprog=this.fechaamericana(this.jdc_fechaprogramada.getDate());
      String sfechaini=this.fechaamericana(this.jdc_rangoini.getDate());
      String sfechafin=this.fechaamericana(this.jdc_rangofinal.getDate());
      String confirma="";
      String texto="select * from x1_supervision_insumos_doctocxc_insert('"+sfechaprog+"','"+sfechaini+"','"+sfechafin+"','"+this.jtf_describe.getText().toUpperCase().trim()+"','"+this.jtf_observaindica.getText().toUpperCase().trim()+"',"+variables_global.getId_empleado()+","+variables_global.getdepartamento()+");";
      try
            {
            rs = x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
               while (rs.next())
                    {
                      confirma=rs.getString(1);
                    }
             }
            catch(Exception e)
            {
                System.out.println(e.getMessage());
            }
         if (confirma.equals("1"))
              {
                JOptionPane.showMessageDialog(null,"Gracias tu Documento ha sido Creado Correctamente", "Sistema Integral CxC",1);
                this.jtf_describe.setText("");
                this.jtf_observaindica.setText("");
                this.jtf_describe.getText();
              }
         else
              {
                JOptionPane.showMessageDialog(null,"Error Consulte con Su Administrador", "Sistema Integral CxC",1);
                this.jtf_describe.getText();
              }
   }

private void carga_datos_catdoctoinsucxc(int opcion,String textobusca,int departame)
    {
       //invoco al metodo que trae el recordset de datos
       //voy por el detalle del documento
       this.LimpiarJTabledocto();
      DecimalFormat miformat = new DecimalFormat("###,###,###,###");
       Object[] fnewRow = new Object[8];
       float total=0;
       rs = x.sieuno_executediversosv2("select * from x1_supervision_insumos_doctocxc_cat("+opcion+",'"+textobusca+"',"+departame+") as (id integer,fechaaplica date,fecharevisa date,fechacobroini date, fechacobrofin date,describe text,observa text,idstatus smallint,idcreodocto integer,idsuperviso integer,iddepartmen integer,nombrecrea character varying(50),nombresupervisa character varying(50),nombreapatsuper character varying(50),describedepta character varying(80),status_des character varying(25),totaldocto numeric);",variables_global.getconexiongral());
        try
         {
            while (rs.next())
                {
                        fnewRow[0]=rs.getString("describedepta");
                        fnewRow[1]=rs.getString("idstatus")+":"+rs.getString("status_des");
                        fnewRow[2]=rs.getString("id")+":"+rs.getString("describe");
                        fnewRow[3]="<html><p align=justify>"+this.fechaeuropea(rs.getString("fechaaplica"))+"<br>"+this.DiaSemana(this.fechaeuropea(rs.getString("fechaaplica")))+"</p></html>";
                        if(rs.getString("fecharevisa") != null )
                            {
                                   fnewRow[4]="<html><p align=justify>"+this.fechaeuropea(rs.getString("fecharevisa"))+"<br>"+this.DiaSemana(this.fechaeuropea(rs.getString("fecharevisa")))+"</p></html>";
                            }
                        else
                            {
                                   fnewRow[4]="";
                            }
                        //fnewRow[5]="<html><p align=justify>"+this.fechaeuropea(rs.getString("fechacobroini"))+" A "+this.fechaeuropea(rs.getString("fechacobroini"))+"<br>"+this.DiaSemana(this.fechaeuropea(rs.getString("fechacobroini")))+" A "+this.DiaSemana(this.fechaeuropea(rs.getString("fechacobroini")))+"</p></html>";
                        fnewRow[5]=rs.getString("observa");
                        fnewRow[6]=miformat.format(rs.getFloat("totaldocto"));
                        total+=rs.getFloat("totaldocto");
                        jtable_modelo_catdoctos.addRow(fnewRow);
                }
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
       this.cambiartamanofilas();
       this.jtf_totalgral.setText(miformat.format(total));
      }
void LimpiarJTabledocto()
 {
     //limpiar la tabla
    while(this.jtable_modelo_catdoctos.getRowCount()>0)this.jtable_modelo_catdoctos.removeRow(0);
 }

void cambiartamanofilas()
{
     //limpiar la tabla
    int numerofilas=this.jtable_modelo_catdoctos.getRowCount();
        for(int i = 0 ;i < numerofilas; i++)
           {
                jt_catdoctoscxc.setRowHeight(i, 30);
           }
}
    private void jt_catdoctoscxcMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jt_catdoctoscxcMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jt_catdoctoscxcMouseClicked

    private void jbtn_cerrardoctoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_cerrardoctoActionPerformed
        // TODO add your handling code here:
        if (this.jtable_modelo_empleadocxc_detalle.getRowCount()>0)
            {
                    if(JOptionPane.showConfirmDialog(null, "Desea Cerrar este Domcumento?")==0) {
                        this.agregardoctocxc_actualiza(1,fdoctoactual ,"");
                        this.jmni_actualizarActionPerformed(evt);
                    }
            }
            else
            {
                    JOptionPane.showMessageDialog(null,"Error! No existen registros del documento", "Docto CXC: Ayuda",1);
            }
}//GEN-LAST:event_jbtn_cerrardoctoActionPerformed

    private void jmni_actualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_actualizarActionPerformed
        // TODO add your handling code here:
        
                 if (variables_global.getnivelusu()==3)
                    {
                        textobuscaemplea=String.valueOf(variables_global.getdepartamento());
                        opcioncatalogo=1;
                        this.carga_datos_catdoctoinsucxc(1,"",Integer.valueOf(variables_global.getdepartamento()));
                    }
                  else
                    {
                        this.carga_datos_catdoctoinsucxc(0,"",0);
                    }
          
    }//GEN-LAST:event_jmni_actualizarActionPerformed

    private void jbtn_recibircorporativoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_recibircorporativoActionPerformed
        // TODO add your handling code here:
        if(JOptionPane.showConfirmDialog(null, "Recibir en Corporativo, Las CxC Quedaran Confirmadas, esta seguro?")==0) {
             this.agregardoctocxc_actualiza(2,fdoctoactual,"");
             this.jmni_actualizarActionPerformed(evt);
        }
}//GEN-LAST:event_jbtn_recibircorporativoActionPerformed

    private void jbtn_recibidireccionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_recibidireccionActionPerformed
        // TODO add your handling code here:
          if(JOptionPane.showConfirmDialog(null, "Recibir en Dereccion, este Documento Cambiara de Estatus, esta seguro?")==0) {
             this.agregardoctocxc_actualiza(3,fdoctoactual,"");
             this.jmni_actualizarActionPerformed(evt);
        }
    }//GEN-LAST:event_jbtn_recibidireccionActionPerformed

    private void jbtn_imprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_imprimirActionPerformed
        // TODO add your handling code here:
         this.imprimir_docto(0,this.jtf_totaldocto.getText(),String.valueOf(fdoctoactual),this.jtf_departamento.getText(),this.jtf_describedocto.getText());
    }//GEN-LAST:event_jbtn_imprimirActionPerformed

    private void jcbx_filtrostatusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbx_filtrostatusActionPerformed
        // TODO add your handling code here:
          if (controlcomboinsu > 0 ) {
            String arreglo_tipoinsu[]=this.jcbx_filtrostatus.getSelectedItem().toString().split(":");
             this.carga_datos_catdoctoinsucxc(2,arreglo_tipoinsu[0],0);
        }
    }//GEN-LAST:event_jcbx_filtrostatusActionPerformed

    private void jmni_scapeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_scapeActionPerformed
        // TODO add your handling code here:
        this.jmni_salirActionPerformed(evt);
    }//GEN-LAST:event_jmni_scapeActionPerformed
private void iniciar_modelo_catalogocobros()
    {
        jtable_modelo_catdoctos=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo_catdoctos.addColumn("<html><b>Departamento</b></html>");
        jtable_modelo_catdoctos.addColumn("<html><b>status</b></html>");
        jtable_modelo_catdoctos.addColumn("<html><b>id/Descripcion</b></html>");
        jtable_modelo_catdoctos.addColumn("<html><b>Fecha</b></html>");
        jtable_modelo_catdoctos.addColumn("<html><b>F.Revisado</b></html>");
        jtable_modelo_catdoctos.addColumn("<html><b>Observaciones</b></html>");
        jtable_modelo_catdoctos.addColumn("<html><b>Total</b></html>");
    }
private void iniciar_modelo_catalogocobros_detalle()
    {
        jtable_modelo_empleadocxc_detalle=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo_empleadocxc_detalle.addColumn("<html><b>Empleado</b></html>");
        jtable_modelo_empleadocxc_detalle.addColumn("<html><b>Factura</b></html>");
        jtable_modelo_empleadocxc_detalle.addColumn("<html><b>Abono</b></html>");
        jtable_modelo_empleadocxc_detalle.addColumn("<html><b>Observaciones</b></html>");
    }
private void iniciar_modelo_empleado()
    {
        jtable_modelo_empleado=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo_empleado.addColumn("<html><b>Dep.</b></html>");
        jtable_modelo_empleado.addColumn("<html><b>Puesto</b></html>");
        jtable_modelo_empleado.addColumn("<html><b>Nombre</b></html>");
        jtable_modelo_empleado.addColumn("<html><b>Saldo</b></html>");
    }

private void iniciar_modelo_empleado_cxc()
    {
        jtable_modelo_empleadocxc=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo_empleadocxc.addColumn("<html><b>Empleado</b></html>");
        jtable_modelo_empleadocxc.addColumn("<html><b>Docto</b></html>");
        jtable_modelo_empleadocxc.addColumn("<html><b>Fecha</b></html>");
        jtable_modelo_empleadocxc.addColumn("<html><b>Piezas</b></html>");
        jtable_modelo_empleadocxc.addColumn("<html><b>Importe</b></html>");
        jtable_modelo_empleadocxc.addColumn("<html><b>Saldo</b></html>");
    }
private void jt_empleadocxcMouseClicked(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
    }
private void dioclickabonar(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:

    if (statusactual==1)
        {
         DecimalFormat miformat = new DecimalFormat("###,###,###,###");
         float cantidad=0,totaldocto=0;
         int error=0;
         int fila = jt_empleadocxc.getSelectedRow();
         String abono=JOptionPane.showInputDialog("Ingresa Importe de Abono:");
         if (abono.length() > 0)
               {
                    try{

                            cantidad = Float.valueOf(abono);
                            System.out.println("Ok esta bien");

                    }catch (NumberFormatException nfe) {

                            cantidad=0;
                            error=1;
                            System.out.println("ERROR");

                   }
               }
          if (error==0)
                   {
                   if(JOptionPane.showConfirmDialog(null, "<html><h2>Abono A "+this.jt_empleadocxc.getValueAt(fila, 0).toString()+":"+cantidad+",Es correcto?</h2></html>")==0){
                          this.agregardoctocxc_detalle(fdoctoactual, fempleadoactual,this.jt_empleadocxc.getValueAt(fila, 1).toString(),cantidad,"");
                          this.creabono_adddetalle_tabla(this.jt_empleadocxc.getValueAt(fila, 0).toString(),this.jt_empleadocxc.getValueAt(fila, 1).toString(), cantidad, "");
                          totaldocto=Float.valueOf(this.jtf_totaldocto.getText().toString().replace(",", ""))+cantidad;
                          this.jtf_totaldocto.setText(miformat.format(totaldocto));
                        }
                   }
          else
                 {
                    JOptionPane.showMessageDialog(null,"Error!", "Ingrese Cantidad Numerica : Ayuda",1);
                 }
         }
        else
            {
                    JOptionPane.showMessageDialog(null,"Error!", "Documento Cerrado Cree Otro documento",1);
            }
        //setVisible(false);
    }

private void creabono_adddetalle_tabla(String empleado,String factura ,float importe, String observacion)
{
   String codigoactual="";
   float cantidadanterior=0,cantidadactual=0,totalpiezasf=0;
   int encontrado=0;
    Object[] fnewRow = new Object[4];
       //invoco al metodo que trae el recordset de datos

                fnewRow[0]=empleado;
                fnewRow[1]=factura;
                fnewRow[2]=importe;
                fnewRow[3]=observacion;
                
                //totalpiezasf=Float.valueOf(this.jtf_totalpiezas.getText().replace(",",""))+Float.valueOf(cantidad);
                //this.jtf_totalpiezas.setText(String.valueOf(totalpiezasf));
                jtable_modelo_empleadocxc_detalle.addRow(fnewRow);
               // cantidadactual=Float.valueOf(cantidad);
}
private void agregardoctocxc_actualiza(int opcion, int iddocto, String observacion)
    {
       //invoco al metodo que trae el recordset de datos
    int operacion=0;
    rs = x.sieuno_executediversosv2("select * from x1_supervision_insumos_doctocxc_actualiza("+opcion+","+iddocto+",'"+observacion+"');",variables_global.getconexiongral());
        try
         {
            while (rs.next())
                {
                       operacion=rs.getInt(1);
                }
        }
        catch(Exception e)
            {
                System.out.println(e.getMessage());
            }
       if (operacion==1)
                {
                    JOptionPane.showMessageDialog(null,"Documento Cerrado Correctamente","Sistema Integral(Insumos CxC: Agregar Cobros) : Ayuda",1);
                }
       else
                {
                    JOptionPane.showMessageDialog(null,"Error Documento No Cerrado Consulte a Su administrador", "Sistema Integral(Agregar Cobros) : Ayuda",1);
                }
     }

private void agregardoctocxc_detalle(int folio,int empleado,String factura,float cantidad,String observacodigo)
    {
       //invoco al metodo que trae el recordset de datos
    int encontrado=0;
    rs = x.sieuno_executediversosv2("select * from x1_supervision_insumos_doctocxc_insert_detalle("+folio+","+empleado+",'"+factura+"',"+cantidad+",'"+observacodigo+"');",variables_global.getconexiongral());
        try
         {
            while (rs.next())
                {
                       encontrado=rs.getInt(1);
                }
         }
        catch(Exception e)
            {
                System.out.println(e.getMessage());
            }
       if (encontrado==1)
              {
                   // this.creainventario_adddetalle_tabla(rs.getString("id"),rs.getString("claveproducto"),rs.getString("descrip"),rs.getString("precio"),String.valueOf(cantidad),observacodigo);
              }
       else
              {
               //JOptionPane.showMessageDialog(null,"Error Clave:"+codigoenvia+" No existe!", "Sistema Integral(Inventarios: Alta) : Ayuda",1);
              }
    }

private void jt_catempleadossaldoMouseClicked(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
    }

private void carga_datos_empleado(int opcion,String textobusca)
    {
       //invoco al metodo que trae el recordset de datos
       //voy por el detalle del documento
       this.LimpiarJTableempleadosaldos();
       Object[] fnewRow = new Object[4];
       rs = x.sieuno_executediversosv2("select * from x1distribucion_insumos_consignadossaldo("+opcion+",'"+textobusca+"') as (id integer,nombre text,idtiendaven integer,iddepa smallint,idpuesto smallint,idstatus smallint,foto character varying(80),idsieuno integer,descripdepa character varying(80),describepuesto text,saldo numeric);",variables_global.getconexiongral());
        try
         {
            while (rs.next())
                {
                        fnewRow[0]=rs.getString("iddepa")+":"+rs.getString("descripdepa");
                        fnewRow[1]=rs.getString("idpuesto")+":"+rs.getString("describepuesto");
                        fnewRow[2]=rs.getString("id")+":"+rs.getString("nombre");
                        fnewRow[3]=rs.getString("saldo");
                        jtable_modelo_empleado.addRow(fnewRow);
                }
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
    }
private void carga_datos_empleadocxc(int opcion,String textobusca)
{
       //invoco al metodo que trae el recordset de datos
       //voy por el detalle del documento
    this.LimpiarJTableempleadocxc();
       Object[] fnewRow = new Object[6];
       rs = x.sieuno_executediversosv2("select * from x1distribucion_insumos_salidas_saldosdocto_catalogo("+opcion+",'"+textobusca+"') as (idreg integer,iddocto character varying(12),desta character varying(15),fedoc date,obserdoc character varying(80), tpz numeric,totprecio numeric,idconsiga integer,nombreconsigando text,saldo numeric);",variables_global.getconexiongral());
        try
         {
            while (rs.next())
                 {
                        System.out.println("historial cxc");
                        fnewRow[0]=rs.getString("idconsiga")+":"+rs.getString("nombreconsigando");
                        fnewRow[1]=rs.getString("iddocto");
                        fnewRow[2]=this.fechaeuropea(rs.getString("fedoc"));
                        fnewRow[3]=rs.getString("tpz");
                        fnewRow[4]=rs.getString("totprecio");
                        fnewRow[5]=rs.getString("saldo");
                        jtable_modelo_empleadocxc.addRow(fnewRow);
                }
        }
        catch(Exception e)
            {
                System.out.println(e.getMessage());
            }
}

void LimpiarJTableempleadocxc()
 {
     //limpiar la tabla
    while(this.jtable_modelo_empleadocxc.getRowCount()>0)this.jtable_modelo_empleadocxc.removeRow(0);
 }
void LimpiarJTableempleadosaldos()
 {
     //limpiar la tabla
    while(this.jtable_modelo_empleado.getRowCount()>0)this.jtable_modelo_empleado.removeRow(0);
 }

private void carga_datos_docto_detalle(int opcion,String textobusca)
    {
       //invoco al metodo que trae el recordset de datos
       //voy por el detalle del documento
    this.LimpiarJTableempleadocxcdetalle();
       Object[] fnewRow = new Object[4];
       rs = x.sieuno_executediversosv2("select * from x1distribucion_supervision_insumos_doctocxc_detalle("+opcion+",'"+textobusca+"') as (id_detalle integer,id_insudocto integer,idempleado integer,factura character varying(12),cantidad numeric,observa text,nombreasignado text);",variables_global.getconexiongral());
        try
         {
            while (rs.next())
                {
                        fnewRow[0]=rs.getString("idempleado")+":"+rs.getString("nombreasignado");
                        fnewRow[1]=rs.getString("factura");
                        fnewRow[2]=rs.getString("cantidad");
                        fnewRow[3]=rs.getString("observa");
                        jtable_modelo_empleadocxc_detalle.addRow(fnewRow);
                }
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
    }
void LimpiarJTableempleadocxcdetalle()
 {
     //limpiar la tabla
    while(this.jtable_modelo_empleadocxc_detalle.getRowCount()>0)this.jtable_modelo_empleadocxc_detalle.removeRow(0);
 }

 private String  fechaeuropea(String fecha) {
         //resibe cadena de fecha en formato americano yyyy-MM-dd
        java.util.Date fechaestaeuropa=null;
       SimpleDateFormat formateadorestaeuropa = new SimpleDateFormat("dd-MM-yyyy");
       String cadenafecha="";
        try
         {
          fechaestaeuropa = formateadoresta.parse(fecha);
         }
        catch (ParseException e)
          {
             //Error, la cadena de texto no se puede convertir en fecha.
          }
       cadenafecha= formateadorestaeuropa.format(fechaestaeuropa);
       return cadenafecha;
    }
 private String  fechaeuropea(Date fecha) {
       SimpleDateFormat formateadorestaeuropa = new SimpleDateFormat("dd-MM-yyyy");
       String cadenafecha="";
       cadenafecha= formateadorestaeuropa.format(fecha);
       return cadenafecha;
    }
 private void dioclickdoctos(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
         //System.out.println("dio doble  indicadores");
                DecimalFormat miformat = new DecimalFormat("###,###,###,###");
                int fila = jt_catdoctoscxc.getSelectedRow();
                String idcadena[]=this.jt_catdoctoscxc.getValueAt(fila, 2).toString().split(":");
                fdoctoactual=Integer.valueOf(idcadena[0]);
               
                this.carga_datos_docto_detalle(0, String.valueOf(fdoctoactual));
                this.jtf_totaldocto.setText(miformat.format(Float.valueOf(this.jt_catdoctoscxc.getValueAt(fila, 6).toString().replace(",", ""))));
                //System.out.println("doctos:"+fdoctoactual);
                this.jbtn_cerrardocto.setVisible(false);
                String idstatusdocto[]=this.jt_catdoctoscxc.getValueAt(fila, 1).toString().split(":");
                statusactual=Integer.valueOf(idstatusdocto[0]);
                if (statusactual==1)
                    {
                        this.carga_datos_empleado(opcioncatalogo,textobuscaemplea);
                        this.jbtn_cerrardocto.setVisible(true);
                        this.jbtn_recibircorporativo.setVisible(false);
                    }
                if (statusactual==2)
                    {
                        this.jbtn_cerrardocto.setVisible(false);
                        this.jbtn_recibircorporativo.setVisible(true);
                    }
                if (statusactual==3)
                    {
                        this.jbtn_cerrardocto.setVisible(false);
                        this.jbtn_recibircorporativo.setVisible(false);
                        this.jbtn_recibidireccion.setVisible(true);
                    }
                    this.jtf_fechadocto.setText(this.jt_catdoctoscxc.getValueAt(fila, 3).toString().replace("<html><p align=justify>", "").replace("</p></html>","" ).replace("<br>", ":"));
                    this.jtf_departamento.setText(this.jt_catdoctoscxc.getValueAt(fila, 0).toString());
                    this.jtf_describedocto.setText(this.jt_catdoctoscxc.getValueAt(fila, 2).toString().replace(",", ""));
               //this.carga_datos_detalleinve(ftienda, ffoliopadre,1,idcadena);
    }
 private void diodblclick(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
         System.out.println("dio doble  click");
                int fila = jt_catempleadossaldo.getSelectedRow();
                String idcadena[]=this.jt_catempleadossaldo.getValueAt(fila, 1).toString().split(":");
                String idcadenaemp[]=this.jt_catempleadossaldo.getValueAt(fila, 2).toString().split(":");
               // this.carga_datos_cxc(Integer.valueOf(idcadena[0]));
                fempleadoactual=Integer.valueOf(idcadenaemp[0]);
               this.carga_datos_empleadocxc(6, String.valueOf(fempleadoactual));
               // this.jt_catpreguntas.requestFocus();
               
    }
 private String DiaSemana(String fe) {
         String dia = "";
       java.util.Date fecha=null;
         try
            {
             fecha = formateador.parse(fe);

           }
        catch (ParseException e)
            {
            //Error, la cadena de texto no se puede convertir en fecha.
            }
        Calendar cal= Calendar.getInstance();
        cal.setTime(fecha);
        //ojo para establecer o recetear cada parte de la fecha por separado
        //cal.set(Calendar.YEAR, fecha.getYear());
        //cal.set(Calendar.MONTH, fecha.getMonth());
        //cal.set(Calendar.DAY_OF_MONTH, fecha.getDay());
        int diaInt = cal.get(Calendar.DAY_OF_WEEK);
        switch (diaInt) {
            case 1:
                dia = "Domingo";
                break;
            case 2:
                dia = "Lunes";
                break;
            case 3:
                dia = "Martes";
                break;
            case 4:
                dia = "Miercoles";
                break;
            case 5:
                dia = "Jueves";
                break;
            case 6:
                dia = "Viernes";
                break;
            case 7:
                dia = "Sabado";
                break;

        }
        return dia;
    }
 private String fechaamericana(Date fe) {
       SimpleDateFormat formateadorestaeuropa = new SimpleDateFormat("yyyy-MM-dd");
       String cadenafecha="";
       cadenafecha= formateadorestaeuropa.format(fe);
       return cadenafecha;
    }

private void imprimir(int pag,String ptotal,String folio,String abono,String empleado)
    {
     java.util.Date fechahoya=new Date();
     this.objimpresora=new insumos_salidas_imprimir();
     this.objimpresora.setOneItem_cadenas_a_imprimir("Abono Uniformes");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Fecha:"+this.fechaeuropea(fechahoya)+"");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Consignado A:"+empleado+"");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Folio Documento:"+folio+"");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Abono:"+abono+"");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Entrega: ______________");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Recibio: ______________");
     //this.objimpresora.setOneItem_cadenas_a_imprimir("..");
     //this.objimpresora.setOneItem_cadenas_a_imprimir("..");
     //this.objimpresora.setOneItem_cadenas_a_imprimir("..");
     //this.objimpresora.setOneItem_cadenas_a_imprimir("..");
     //this.objimpresora.setOneItem_cadenas_a_imprimir("..");
     //this.objimpresora.setOneItem_cadenas_a_imprimir("..");
     //this.objimpresora.setOneItem_cadenas_a_imprimir("..");
     this.objimpresora.setOneItem_cadenas_a_imprimir("*");
     this.objimpresora.setObjeto_tabla(jt_catdoctoscxc_detalle);
     this.objimpresora.imprimir_all(3,pag);
    }
private void imprimir_docto(int pag,String ptotal,String folio,String departamento,String descripcion)
    {
     java.util.Date fechahoya=new Date();
     this.objimpresora=new insumos_salidas_imprimir();
     this.objimpresora.setOneItem_cadenas_a_imprimir("Abono Uniformes");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Fecha:"+this.fechaeuropea(fechahoya)+"");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Descripcion:"+descripcion+"");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Folio Documento:"+folio+"");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Depart:"+departamento+"");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Total Docto:$"+ptotal+"");
     this.objimpresora.setOneItem_cadenas_a_imprimir("*");
     this.objimpresora.setObjeto_tabla(jt_catdoctoscxc_detalle);
     this.objimpresora.imprimir_all(4,pag);
    }

private void dioclickimprime(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
         //System.out.println("dio doble  indicadores");
    int fila = jt_catdoctoscxc_detalle.getSelectedRow();
    this.imprimir(0,this.jt_catdoctoscxc_detalle.getValueAt(fila,2).toString(),this.jt_catdoctoscxc_detalle.getValueAt(fila,1).toString(),this.jt_catdoctoscxc_detalle.getValueAt(fila,2).toString()+"", this.jt_catdoctoscxc_detalle.getValueAt(fila,0).toString()+"");
               //this.carga_datos_detalleinve(ftienda, ffoliopadre,1,idcadena);
    }
private void jt_catdoctoscxc_detalleMouseClicked(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
    }

private void loadcombostatusdocto(){
          rs = x.sieuno_executediversosv2("select * from x1_supervision_insumos_doctocxc_status() as (id smallint,statusdescrip character varying(25));",variables_global.getconexiongral());
            try
            {
               while (rs.next())
                    {
                      this.jcbx_filtrostatus.addItem(rs.getString("id")+":"+rs.getString("statusdescrip"));
                    }
            }
            catch(Exception e)
            {
                System.out.println(e.getMessage());
            }
    }

    /**
    * @param args the command line arguments
    */


    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new insumos_salidas_consignadocxc().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JButton jbtn_cerrardocto;
    private javax.swing.JButton jbtn_guardasolicitud;
    private javax.swing.JButton jbtn_imprimir;
    private javax.swing.JButton jbtn_recibidireccion;
    private javax.swing.JButton jbtn_recibircorporativo;
    private javax.swing.JComboBox jcbx_filtrostatus;
    private com.toedter.calendar.JDateChooser jdc_fechaprogramada;
    private com.toedter.calendar.JDateChooser jdc_rangofinal;
    private com.toedter.calendar.JDateChooser jdc_rangoini;
    private javax.swing.JMenuItem jmni_actualizar;
    private javax.swing.JMenuItem jmni_salir;
    private javax.swing.JMenuItem jmni_scape;
    private javax.swing.JTable jt_catdoctoscxc;
    private javax.swing.JTable jt_catdoctoscxc_detalle;
    private javax.swing.JTable jt_catempleadossaldo;
    private javax.swing.JTable jt_empleadocxc;
    private javax.swing.JTextField jtf_departamento;
    private javax.swing.JTextField jtf_describe;
    private javax.swing.JTextField jtf_describedocto;
    private javax.swing.JTextField jtf_fechadocto;
    private javax.swing.JTextField jtf_observaindica;
    private javax.swing.JTextField jtf_totaldocto;
    private javax.swing.JTextField jtf_totalgral;
    // End of variables declaration//GEN-END:variables
private insumos_salidas_imprimir objimpresora;
}
